package cn.itcast.service.dept.impl;

import cn.itcast.dao.dept.DeptDao;
import cn.itcast.domain.Dept;
import cn.itcast.service.dept.DeptService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class DeptServiceImpl implements DeptService {

    @Autowired
    private DeptDao deptDao;

    @Override
    public PageInfo findAll(int pageNum, int pageSize, String companyId) {

        PageHelper.startPage(pageNum,pageSize);
        List<Dept> list = deptDao.findAll(companyId); //分页查
        PageInfo pb = new PageInfo(list);
        return pb;
    }

    @Override
    public List<Dept> findAllDept(String company_id) {
        List<Dept> list = deptDao.findAll(company_id); //全查
        return list;
    }

    @Override
    public void save(Dept dept) {
        deptDao.save(dept);
    }

    @Override
    public Dept findById(String id) {
        return deptDao.findById(id);
    }

    @Override
    public void update(Dept dept) {
        deptDao.update(dept);
    }

    @Override
    public void delete(String id) {
        deptDao.delete(id);
    }
}
